#include <windows.h>
#include <guiddef.h>
#include "fourccguid.hpp"
#include <cassert>


namespace MJH
{


FourCCGUID::FourCCGUID(const char* str)
{
    assert(strlen(str) == 4);
    memcpy(&Data1, str, 4);
    Data2 = 0x0000;
    Data3 = 0x0010;
    Data4[0] = 0x80;
    Data4[1] = 0x00;
    Data4[2] = 0x00;
    Data4[3] = 0xAA;
    Data4[4] = 0x00;
    Data4[5] = 0x38;
    Data4[6] = 0x9B;
    Data4[7] = 0x71;
}

FourCCGUID::FourCCGUID(DWORD Data1_)
{
    Data1 = Data1_;    
    Data2 = 0x0000;
    Data3 = 0x0010;
    Data4[0] = 0x80;
    Data4[1] = 0x00;
    Data4[2] = 0x00;
    Data4[3] = 0xAA;
    Data4[4] = 0x00;
    Data4[5] = 0x38;
    Data4[6] = 0x9B;
    Data4[7] = 0x71;
}


bool FourCCGUID::IsFourCC(const GUID& guid)
{
    if (guid.Data2 != 0x0000)
        return false;
        
    if (guid.Data3 != 0x0010)
        return false;
        
    if (guid.Data4[0] != 0x80)
        return false;
        
    if (guid.Data4[1] != 0x00)
        return false;
        
    if (guid.Data4[2] != 0x00)
        return false;
        
    if (guid.Data4[3] != 0xAA)
        return false;
        
    if (guid.Data4[4] != 0x00)
        return false;
        
    if (guid.Data4[5] != 0x38)
        return false;
        
    if (guid.Data4[6] != 0x9B)
        return false;
        
    if (guid.Data4[7] != 0x71)
        return false;
        
    return true;
}


} //end namespace MJH

